package main

import (
	"expvar"
	"fmt"
	"net"
	"net/http"
)

var (
	test = expvar.NewMap("Test")
	testInt = expvar.NewInt("TestInt")
)

func init() {
	test.Add("go", 10)
	test.Add("go1", 10)
}

/*
http://localhost:8080/debug/vars
可查看全局信息
*/
func main() {
	update()
	sock, err := net.Listen("tcp", "localhost:8080")
	if err != nil {
		panic("error")
	}
	go func() {
		http.Serve(sock, nil)
	}()
	select {}
}

func update()  {
	pubFloat := expvar.NewFloat("Float")
	pubFloat.Set(66)
	pubFloat.Add(0.1)
	test.Set("go",pubFloat)

	testInt.Set(66)
	testInt.Add(2)
	fmt.Println("int", testInt.String())
	fmt.Println("go", test.String())
}
